class Solution {
public:
    vector<int> missingTwo(vector<int>& nums) {
        int tmp = 0;
        for (auto x : nums) tmp ^= x;
        for (int i = 1; i <= nums.size() + 2; i++) tmp ^= i;

        int buffi = 0;
        while (1) {
            if (((tmp >> buffi) & 1) == 1) break;
            buffi++;
        }

        int a = 0, b = 0;
        for (auto x : nums) {
            if (((x >> buffi) & 1) == 1) b ^= x;
            else a ^= x;
        }
        for (int i = 1; i <= nums.size() + 2; i++) {
            if (((i >> buffi) & 1) == 1) b ^= i;
            else a ^= i;
        }
        return { a,b };
    }
};